# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=kooha
pkgver=2.0.1
pkgrel=1
pkgdesc="Elegantly record your screen"
url="https://github.com/SeaDve/Kooha"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # blocked by rust/cargo
license="GPL-3.0-or-later"
depends="
	gst-plugin-pipewire
	gst-plugins-good
	pipewire
	xdg-desktop-portal
	"
makedepends="
	cargo
	gettext-dev
	glib-dev
	gst-plugins-base-dev
	gstreamer-dev
	gstreamer-vaapi
	gtk4.0-dev
	libadwaita-dev
	meson
	pulseaudio-dev
	wayland-dev
	x264-dev
	"
checkdepends="
	cmd:desktop-file-validate
	"
subpackages="$pkgname-lang $pkgname-mp4"
source="https://github.com/SeaDve/Kooha/releases/download/v$pkgver/kooha-$pkgver.tar.xz"

prepare() {
	default_prepare

	# Optimize binary for size (but don't use panic=abort here).
	cat >> Cargo.toml <<-EOF

		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "s"
	EOF
}

build() {
	abuild-meson -Db_lto=true . output
	meson compile -j ${JOBS:-0} -C output
}

check() {
	meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

mp4() {
	pkgdesc="Kooha dependencies for recording into MP4 format"
	depends="$pkgname=$pkgver-r$pkgrel gst-plugins-ugly"

	mkdir -p "$subpkgdir"
}

sha512sums="
230d3c9547f586393568772d346dc384c2f9f242c936e86edaa0237f762df409173da2ec10a8ceea7490d944199d63e88eaef1c717632e8dccde66062a7e4fd7  kooha-2.0.1.tar.xz
"
